<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>发送离线offer</title>
    <script src="../../js/commons.js"></script>
    <script src="../../js/jquery-3.6.0.js"></script>
    <script src="../../js/layui.js"></script>
    <link href="../../css/layui.css">
</head>
<body>
<div class="layui-container" style="align-items: center">
    <div class="layui-row">
        <div class="layui-col-md6"></div>
    </div>
</div>

    <form onsubmit="return uplaodOffer()" style="align-content: center">
<!--      <label>请选择发送人：</label>-->
        <div class="layui-form-item">
            <label class="layui-form-label">请选择发送人</label>
            <div class="layui-input-block">
                <select name="interest" lay-filter="aihao">
                    <option value=""></option>
                    <option value="0">写作</option>
                </select>
            </div>
        </div>
        <br>

        <br>
      <label>请选择文件：</label><input type="file"><br><br>
       <input type="submit" value="发送offer"><br>
    </form>

    <script>

        $.ajax({
            url:URL + "recruiter/offer/sendOfflineOffer",
            type:"post",
            dataType:"json",
            success:function (result) {

                if (result.code == 2) {

                    $("select[name='interest']").empty();

                    let da =result.data.data;

                    for (let i =0;i<da.length;i++){
                        $("select[name='interest']").append("<option value='"+da[i].uid+"'>"+da[i].username+"</option>");

                    }

                } else if (result.code == 0) {//上传成功

                }
            }
        })





        function uplaodOffer (){
            let formData = new FormData();
            formData.append("offlineOffer",$("input[type='file']")[0].files[0]);
            formData.append("username",$("#username").val());
            $.ajax({
                url:URL + "recruiter/offer/sendOfflineOffer",
                type:"post",
                data:formData,
                headers: {"token":localStorage.getItem("token")},
                dataType:"json",
                cache:false,
                processData: false,
                contentType:false,
                success:function (result){
                    alert(result.msg)
                    if (result.code == 2){
                        window.location.href = "login.html";
                    } else if (result.code == 0){//上传成功
                        window.location.href = "main.html";
                    }else if(result.code==1){
                        alert(result.msg);
                    }
                }
            })

            return false;
        }
    </script>
</body>
</html>